<template>
  <div>
    <el-menu router :default-active="$route.path" :default-openeds="openedsMenuIndex">
      <el-menu-item index="/">
        <template slot="title">
          <i class="iconfont icon-yibiaopan"></i>仪表盘</template>
      </el-menu-item>
      <!-- <el-menu-item index="/">
        <template slot="title">
          <i class="iconfont icon-jiankong"></i>监控</template>
      </el-menu-item> -->
      <el-submenu index="1">
        <template slot="title">
          <i class="iconfont icon-yonghu"></i>用户</template>
        <!-- <el-menu-item index="/organizational">组织架构</el-menu-item> -->
        <el-menu-item index="/users">用户账号</el-menu-item>
      </el-submenu>
      <el-submenu index="2">
        <template slot="title">
          <i class="iconfont icon-xitong2"></i>系统</template>
        <el-menu-item index="/systems">业务系统</el-menu-item>
        <el-menu-item index="/roles">系统角色</el-menu-item>
        <el-menu-item index="/permissions">资源权限</el-menu-item>
      </el-submenu>
      <el-submenu index="3">
        <template slot="title">
          <i class="iconfont icon-authorise"></i>授权</template>
        <el-menu-item index="/authorization/role">角色授权</el-menu-item>
        <el-menu-item index="/authorization/user">用户授权</el-menu-item>
      </el-submenu>
    </el-menu>
  </div>
</template>

<style scoped>
.iconfont {
  vertical-align: middle;
  margin-right: 0.3125rem;
  width: 1.5rem;
  text-align: center;
  /* font-size: 1.125rem; */
  font-size: 1.25rem;
  speak: none;
  font-style: normal;
  font-weight: 400;
  font-variant: normal;
  text-transform: none;
  line-height: 1;
  display: inline-block;
}
</style>

<script>
export default {
  name: "MyMenu",
  data() {
    return {};
  },
  computed: {
    //默认展开目录序号
    openedsMenuIndex() {
      if (this.$route.path.indexOf("/users") > -1) {
        return ["1"];
      } else if (this.$route.path.indexOf("/systems") > -1) {
        return ["2"];
      } else if (this.$route.path.indexOf("/roles") > -1) {
        return ["2"];
      } else if (this.$route.path.indexOf("/permissions") > -1) {
        return ["2"];
      } else if (this.$route.path.indexOf("/authorization") > -1) {
        return ["3"];
      } else {
        return ["0"];
      }
    }
  }
};
</script>
